import React from 'react'
import {
  useNavigate,
  useParams,
  useLocation,
  useSearchParams,
  Navigate,
} from 'react-router-dom'

export default function Login() {
  // 接收路由参数. params是一个对象
  const params = useParams()
  console.log('路由参数: ', params)

  // 接收state数据
  const location = useLocation()
  console.log('state', location.state)

  // 接收查询字符串
  const [query, setQuery] = useSearchParams()
  console.log(query.get('xxx'))

  return (
    <h1>
      Login,
      {/* 只要Navigate组件被解析,就会立刻修改浏览器地址栏的路径 */}
      {/* <Navigate to="/home"></Navigate> */}
    </h1>
  )
}
